package com.summo.demo.controller;

import com.summo.demo.config.context.GlobalUserContext;
import com.summo.demo.config.log.Log;
import com.summo.demo.entity.UserDO;
import com.summo.demo.model.request.AddReq;
import com.summo.demo.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class IndexController {

    @Autowired
    private UserService userService;

    @GetMapping("/index")
    @Log(methodDesc = "首页")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("welcome");
        UserDO userDO = userService.queryById(GlobalUserContext.getUserContext().getUserId());
        modelAndView.addObject("userName", userDO.getUserName());
        return modelAndView;
    }

}
